package com.beiding.v2.base;

import java.util.List;

public interface IContext {

    /*
    回调
     */
    List<IUnitHandler> getHandlers();

    /*
    内用
     */
    default IUnitHandler getHandle(IUnit unit) {
        for (IUnitHandler handler : getHandlers()) {
            if (handler.canHandle(unit)) {
                return handler;
            }
        }
        throw new NoSuitedHandlerException(unit);
    }

}
